<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
  <meta charset="utf-8">
  <title>编辑比赛</title>
  <link rel="stylesheet" th:href="@{../../static/layui/css/layui.css}" href="../../static/layui/css/layui.css" media="all">
</head>

<body>

<form class="layui-form" action="" >
  <div class="layui-form-item">
    <label class="layui-form-label">比赛ID</label>
    <div class="layui-input-block">
      <input readonly type="text" th:value="${game.getMatchId()}" disabled name="matchId" required  lay-verify="required" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">比赛名称</label>
    <div class="layui-input-block">
      <input type="text" name="mname" th:value="${game.getMname()}" required  lay-verify="required"  autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">比赛地点</label>
    <div class="layui-input-block">
      <input type="text" name="matchAddress" th:value="${game.getMatchAddress()}" required  lay-verify="required" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">比赛信息</label>
    <div class="layui-input-block">
      <input type="text" name="matchInfo"  th:value="${game.getMatchInfo()}"  required  lay-verify="required" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">比赛状态</label>
    <div class="layui-input-block">
      <select name="status" lay-verify="required">
        <option name="status" th:selected="${game.getStatus()==1}" value="1">进行中</option>
        <option name="status" th:selected="${game.getStatus()==0}" value="0">未开始</option>
        <option name="status" th:selected="${game.getStatus()==2}" value="2">比赛结束</option>
      </select>
    </div>

  </div>


  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>


<script th:src="@{../../static/layui/layui.js}"></script>
<script th:src="@{../../static/js/eleDel.js}" type="text/javascript"></script>
<script th:src="@{../../static/mysource/js/jquery-3.3.1.min.js}"></script>
<script>
  //Demo
  layui.use('form', function(){
    var form = layui.form;
    var layer = layui.layer;


    //提交
    form.on('submit(formDemo)', function(data){
      console.log(data.field)


      $.ajax({
        url: '/game/update' ,
        dataType:"json",
        type:"post",
        data: data.field,
        success:function (data){
          console.log(data)

          if (data.flag){
            var msg = data.msg
            layer.msg(msg,{icon:6});

          }



        }
      })



      return false;
    });
  });
</script>
</body>

</html>